/*! \file MemoryMappedFile_unix.inl
 *	\brief
 *
 *	created:	2010/11/23
 *	created:	23:11:2010   10:13
 *	filename: 	C:\src\tactics-engine\libs\io\unix\MemoryMappedFile_unix.inl
 *	file path:	C:\src\tactics-engine\libs\io
 *	file base:	MemoryMappedFile
 *	file ext:	inl
 *	author:		Vitalii Trubchaninov
 *				vitalii.trubchaninov@ubisoft.com
 */
namespace tt{
namespace io{

namespace impl{

inline
MemoryMappedHandle::MemoryMappedHandle()
: m_Data(NULL)
, m_Size(0)
{
}

inline
MemoryMappedHandle::MemoryMappedHandle(void* data, Size size)
: m_Data(data)
, m_Size(size)
{
}

inline
void MemoryMappedHandle::Swap(MemoryMappedHandle& other)
{
	std::swap(m_Data, other.m_Data);
	std::swap(m_Size, other.m_Size);
}

inline
const void* MemoryMappedHandle::GetData() const
{
	return m_Data;
}

Size MemoryMappedHandle::GetSize() const
{
	return m_Size;
}

Bool MemoryMappedHandle::Valid() const
{
	return m_Data != NULL;
}

MemoryMappedHandle::operator bool() const
{
	return Valid();
}

} //namespace impl

//////////////////////////////////////////////////////////////////////
inline
bool MemoryMappedFilePS::Writeable() const
{
	return (m_Mode == O_RDWR) || (m_Mode == O_WRONLY);
}

inline
Size MemoryMappedFilePS::GetSize() const
{
	return m_Data.GetSize();
}

inline
const void* MemoryMappedFilePS::GetData() const
{
	return m_Data.GetData();
}

} //namespace io
} //namespace tt
